package com.egg.basic.controller.web;


import com.egg.basic.util.FileAliyunUtil;
import com.egg.basic.util.FileQiniuUtil;
import com.egg.common.core.model.controller.WebController;
import com.egg.common.core.model.response.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author east
 * @since 2021-11-26
 */
@Slf4j
@Api(tags = WebController.API_PREFIX + "文件中心")
@RestController("/file")
public class WebFileController extends WebController {


    @ApiOperation(value = "七牛云文件上传")
    @PostMapping("/qiniu/public")
    public ResponseData<String> qiniuPublicPost(
            @ApiParam(value = "上传文件") @RequestParam(value = "file") MultipartFile file
    ) {
        return ResponseData.success(FileQiniuUtil.uploadPublic(file));
    }

    @ApiOperation(value = "阿里云云文件上传")
    @PostMapping("/aliyun")
    public ResponseData<String> aliyunPost(
            @ApiParam(value = "上传文件") @RequestParam(value = "file") MultipartFile file
    ) {
        return ResponseData.success(FileAliyunUtil.upload(file));
    }


}

